package com.world.business.kungfu.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.world.business.area.domain.Area;
import com.world.common.controller.BaseController;
import com.world.common.domain.ResponseData;
import com.world.common.domain.PageResult;
import com.world.common.domain.SuccessResponseData;
import com.world.common.enumeration.DelFlagEnum;
import com.world.business.kungfu.domain.KungFu;
import com.world.business.kungfu.domain.query.KungFuPageRequest;
import com.world.business.kungfu.domain.vo.KungFuVO;
import com.world.business.kungfu.service.IKungFuService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 功法
 *
 * @author 邓驴
 * @since 2023-05-31
 */
@Api(tags = "功法")
@RestController
@RequestMapping("/kung/fu")
public class KungFuController extends BaseController<KungFu> {

    @Resource
    private IKungFuService kungFuService;


    @ApiOperation("列表")
    @GetMapping("/list")
    public ResponseData<PageResult<KungFuVO>> list(KungFuPageRequest request) {
        //1.分页条件
        Page<KungFu> page = startPage(request);

        //2.查询条件
        LambdaQueryWrapper<KungFu> queryWrapper = Wrappers.lambdaQuery(KungFu.class);
        queryWrapper.eq(KungFu::getDelFlag, DelFlagEnum.NORMAL.getCode());
        Page<KungFu> result = kungFuService.page(page, queryWrapper);

        //3.结果转化
        PageResult<KungFuVO> pageResult = getPageResult(result, KungFuVO.class);
        return new SuccessResponseData<>(pageResult);
    }

}
